package zhongxin;

import java.io.*;
import java.net.*;


public class Java1 {
	public static void main(String[] args){
		ServerSocket server;
		Socket client;
		OutputStream ops=null;
		InputStream ips=null;
		try {
			server=new ServerSocket(12240);
			client=server.accept();
			String s=client.getInetAddress().getHostAddress();
			System.out.println(s);
			System.out.println();
			ops=client.getOutputStream();
			ips=client.getInputStream();
			BufferedReader br=new BufferedReader(new InputStreamReader(ips));
			PrintWriter pw=new PrintWriter(ops);
			String zx="";
			while(!zx.equals("beybey!")){
				zx=br.readLine();
				pw.write(zx);
				pw.flush();
				System.out.println(zx);
			}
			server.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			ops.close();
			ips.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
